package com.lab.service.impl;

import com.lab.dao.TexDao;
import com.lab.pojo.Texperiment;
import com.lab.service.TexService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("texService")
public class TexServiceImp implements TexService {
    @Resource
    TexDao texDao;
    //查询所有数据
    public List<Texperiment> allTexperiments() {
        return texDao.allTexperiments();
    }
    //添加和修改
    public void saveTexperiment(Texperiment texperiment) {
        try {
            Texperiment t= texDao.findTexById(texperiment.getTeId());
            if (t!=null){
                //修改
                texDao.updateTexperiment(texperiment);
            }else {
                //增加
                texDao.addTexperiment(texperiment);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //删除
    public void deleteTexperiment(Long[] teId) {
        texDao.deleteTexperiment(teId);
    }

    public Texperiment findTexById(Long teId) {
        return texDao.findTexById(teId);
    }
    //实验课程申请
    public void applyTexperiment(Texperiment texperiment) {
        texDao.addTexperiment(texperiment);
    }

    public void unpassTexperiment(Long[] teId) {
        texDao.unpassTexperiment(teId);
    }

    public void passTexperiment(Long[] teId) {
        texDao.passTexperiment(teId);
    }

}
